package aod.android.com.bernay.fixing.adapter;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import java.util.List;

import aod.android.com.bernay.R;
import aod.android.com.bernay.fixing.activity.FixingModelActivity;
import aod.android.com.bernay.fixing.bean.FixingDatabean;
import aod.android.com.bernay.live.adapter.LiveAdapter;
import aod.android.com.bernay.live.bean.LIveListBean;
import chen.lion.hilib.image.ImageLoader;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;

/**
 * <p>文件描述：设备适配器 <p>
 * <p>作者：${SYC}<p>
 * <p>创建时间：2019/4/10<p>
 */
public class FixingAdapter  extends BaseAdapter{
    private List<FixingDatabean.DataBean> inviteBeanList;
    private Context mContext;

    public FixingAdapter(Context mContext, List<FixingDatabean.DataBean> inviteBeanList) {
        this.inviteBeanList = inviteBeanList;
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return inviteBeanList.size();
    }

    @Override
    public Object getItem(int position) {
        return inviteBeanList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

//    public void setOnItemClickListener(ClientInviteHistoryAdapter.OnItemClickListener listener) {
//        this.listener = listener;
//    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        final ViewHolder viewHolder;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.add_fixing_item, null, false);
            viewHolder.fixing_car_name_pattern_tv = convertView.findViewById(R.id.fixing_car_name_pattern_tv);
            viewHolder.fixing_state_tv = convertView.findViewById(R.id.fixing_state_tv);
            viewHolder.live_video_vv = convertView.findViewById(R.id.live_video_vv);
            viewHolder.fixing_model_lay = convertView.findViewById(R.id.fixing_model_lay);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        final FixingDatabean.DataBean fixingDatabean =  inviteBeanList.get(position);
        viewHolder.fixing_car_name_pattern_tv.setText(fixingDatabean.getName()+"("+"出差模式"+")");
//        if(fixingDatabean.getDeviceStatus().equals("1")){
//            viewHolder.fixing_state_tv.setText("离线");
//        }
       // viewHolder.fixing_state_tv.setText(fixingDatabean.getFixingState());
      //  viewHolder.live_video_vv.setUp("http://2449.vod.myqcloud.com/2449_43b6f696980311e59ed467f22794e792.f20.mp4", "http://p.qpic.cn/videoyun/0/2449_43b6f696980311e59ed467f22794e792_1/640", fixingDatabean.getFixingPath());
        viewHolder.fixing_model_lay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mContext.startActivity(new Intent(mContext, FixingModelActivity.class));
            }
        });
        return convertView;
    }


    class ViewHolder {
        private TextView fixing_car_name_pattern_tv;//设备名称和设备模式
        private TextView fixing_state_tv;//设备状态
        private JCVideoPlayer live_video_vv;//播放器
        private LinearLayout fixing_model_lay;//切换模式
    }

}
